package com.gin.no_gay_alliance.viewmodel.notice;

import android.os.Parcel;
import android.os.Parcelable;

import com.gin.nga.response.field.notice.ReplyNotice;

/**
 * 回复提醒
 *
 * @author : ginstone
 * @version : v1.0.0
 * @since : 2023/9/11 10:27
 **/
public class ReplyNoticeModel extends BaseNoticeModel<ReplyNotice> implements Parcelable {
    public static final Creator<ReplyNoticeModel> CREATOR = new Creator<ReplyNoticeModel>() {
        @Override
        public ReplyNoticeModel createFromParcel(Parcel in) {
            return new ReplyNoticeModel(in);
        }

        @Override
        public ReplyNoticeModel[] newArray(int size) {
            return new ReplyNoticeModel[size];
        }
    };
    /**
     * 主题标题
     */
    public String topicTitle;
    /**
     * 主题id
     */
    public Long topicId;
    /**
     * 回复id
     */
    public Long replyId;
    /**
     * 被回复的id
     */
    public Long repliedId;
    /**
     * 页码
     */
    public Integer page;
    public Long authorId;
    public String authorName;

    public ReplyNoticeModel() {
    }

    public ReplyNoticeModel(ReplyNotice replyNotice) {
        super(replyNotice);

        this.topicTitle = replyNotice.getTopicTitle();
        this.topicId = replyNotice.getTopicId();
        this.replyId = replyNotice.getReplyId();
        this.repliedId = replyNotice.getRepliedId();
        this.page = replyNotice.getPage();
        this.authorId = replyNotice.getAuthorId();
        this.authorName = replyNotice.getAuthorName();
    }

    protected ReplyNoticeModel(Parcel in) {
        super(in);
        topicTitle = in.readString();
        if (in.readByte() == 0) {
            topicId = null;
        } else {
            topicId = in.readLong();
        }
        if (in.readByte() == 0) {
            replyId = null;
        } else {
            replyId = in.readLong();
        }
        if (in.readByte() == 0) {
            repliedId = null;
        } else {
            repliedId = in.readLong();
        }
        if (in.readByte() == 0) {
            page = null;
        } else {
            page = in.readInt();
        }
        if (in.readByte() == 0) {
            authorId = null;
        } else {
            authorId = in.readLong();
        }
        authorName = in.readString();
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        super.writeToParcel(dest, flags);
        dest.writeString(topicTitle);
        if (topicId == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeLong(topicId);
        }
        if (replyId == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeLong(replyId);
        }
        if (repliedId == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeLong(repliedId);
        }
        if (page == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeInt(page);
        }
        if (authorId == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeLong(authorId);
        }
        dest.writeString(authorName);
    }
}
